from django import template

register = template.Library()

@register.simple_tag
def user_space(num):
    if int(num) >= 1024 * 1024 * 1024:
        return '%.2f GB' % (num / (1024 * 1024 * 1024))
    elif int(num) >= 1024 * 1024:
        return '%.2f MB' % (num / (1024 * 1024))
    elif int(num) >= 1024:
        return '%.2f KB' % (num / (1024))
    else:
        return '%d B' % num
